package com.zhss.redis.list;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.stream.IntStream;


/**
 * 发送电子邮件的演示
 *
 * @author winston
 * @date 2021/09/23
 */
public class SendEmailDemo {
	static Jedis jedis = new Jedis(new HostAndPort("121.4.79.149", 6379));
	private static String list_key = "mail_queue";

	public static void add() {
		for (int i = 0; i <= 10; i++) {
			try {
				Thread.sleep(3000);
				System.out.println("插入元素" + i);
				jedis.lpush(list_key, String.valueOf(i));
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

	public static void main(String[] args) {
		new Thread(SendEmailDemo::add).start();
		List<String> brpop = jedis.brpop(5, list_key);
		brpop.forEach(System.out::println);
	}
}
